//
// Mutex.cpp for  in /home/lund/Projets/plazza
// 
// Made by florian dewulf
// Login   <dewulf_f@epitech.net>
// 
// Started on  Sun Apr 14 23:42:50 2013 florian dewulf
// Last update Mon Apr 15 20:39:07 2013 florian dewulf
//

#include	"Mutex.hpp"

Mutex::Mutex() : _error(false)
{
  pthread_mutex_init(&(this->_mutex), NULL);
}

Mutex::~Mutex()
{
}

void		Mutex::lock()
{
  if (pthread_mutex_lock(&(this->_mutex)))
    this->_error = true;
}

void		Mutex::unlock()
{
  if (pthread_mutex_unlock(&(this->_mutex)))
    this->_error = true;
}

pthread_mutex_t	Mutex::getMutex() const
{
  return this->_mutex;
}

bool		Mutex::getError() const
{
  return this->_error;
}

void		Mutex::setMutex(pthread_mutex_t &mut)
{
  this->_mutex = mut;
}

void		Mutex::setError(bool booleen)
{
  this->_error = booleen;
}
